<?php
class Register
{
    protected $_at;

    public function registerUser()
    {
        /**
         * @todo remove at maybe
         */
//        $at = Controller::getInstance()->at();

        if('register' == $_REQUEST['action']) {
            $myFile = "test.txt";
            $fh = fopen($myFile, 'a') or die("can't open file");
            $name = $_POST['regName'];
            $pass = md5($_POST['regPass']);

            $verbindung = mysql_connect("localhost","root","");
            //or die ("Die Verbindung konnte nicht erstellt werden");
            mysql_select_db("game");
            $q = 'INSERT INTO Users SET password="' . $pass . '", name="' . $name . '"';
            mysql_query($q);
            mysql_close($verbindung);

            fwrite($fh, $name . "\n");
            fwrite($fh, $pass . "\n");
            fclose($fh);
        }
    }

    /**
     * @return smarty
     */
    public function getAt()
    {
        if (!$this->_at) {
            $this->_at = Controller::getInstance()->at();
        }
        return $this->_at;
    }

    public function setAt($at) {
        $this->_at = $at;
    }
}

